package com.lgq.mydatabackend.mapper;

import com.lgq.mydatabackend.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Map;

public interface UserMapper {
    @Select("select * from user where username = #{username}")
    User findByUsername(String username);

    @Insert("insert into user(username, password, create_time, update_time) values(#{username}, #{password}, now(), now())")
    void register(String username, String password);

    @Update("update user set nickname = #{nickname}, email = #{email}, update_time = now() where id = #{id}")
    void update(User user);

    @Update("update user set user_pic = #{userPic}, update_time = now() where id = #{userId}")
    void updateAvatar(String userPic, Integer userId);

    @Update("update user set password = #{newPwd}, update_time = now() where id = #{userId}")
    void updatePwd(String newPwd, Integer userId);
}
